package util;

import org.apache.commons.lang3.time.DurationFormatUtils;

import java.util.concurrent.TimeUnit;

/**
 * Created by pc on 2015/5/31.
 * 用nanoTime来计算逝去的时间，并用DurationFormatUtils来显示
 */
public class ElaspedTime {
    public static void main(String args[]) throws InterruptedException {
        long now = System.nanoTime();
        Thread.sleep(1200);

        System.out.println("elapsed: " +
                DurationFormatUtils.formatDurationHMS(
                        TimeUnit.MILLISECONDS.convert(System.nanoTime() - now, TimeUnit.NANOSECONDS)));
    }
}
